﻿Option Strict On
Option Explicit On
Option Infer On

Imports System
Imports System.Linq
Imports System.Xml.Linq
Imports System.Collections.Generic
Imports GenDotNet.ObjectModel
Imports <xmlns:orm="http://kadgen.com/KADORM.xsd">

Namespace GenInputMetadata
   Public Class ForeignKeyData
      Inherits BaseData
      Implements IForeignKeyData

      Private mKeys As List(Of IKeyData)

      Public Shared Function Load( _
            ByVal objectData As ObjectData, _
            ByVal element As XElement) _
            As ForeignKeyData
         Dim ret = New ForeignKeyData(objectData.RootData, element)
         ret.mKeys = KeyData.Load(objectData.RootData, From x In element.<orm:ForeignKey>)
         Return ret
      End Function

      Public Shared Function Load( _
                  ByVal objectData As ObjectData, _
                  ByVal elements As IEnumerable(Of XElement)) _
                  As List(Of IForeignKeyData)
         Dim ret = New List(Of IForeignKeyData)
         For Each XElement In elements
            ret.Add(Load(objectData, XElement))
         Next
         Return ret
      End Function

      Private Sub New(ByVal rootData As RootData, _
                      ByVal element As XElement)
         MyBase.New(rootData, element)
      End Sub

#Region "IForeignKeyData Implementation"
      Public ReadOnly Property Keys() As System.Collections.Generic.List(Of IKeyData) Implements IForeignKeyData.Keys
         Get
            Return mKeys
         End Get
      End Property

      Public ReadOnly Property Name() As String Implements IForeignKeyData.Name
         Get
            Return Element.@UniqueName
         End Get
      End Property

      Public ReadOnly Property ObjectName() As String Implements IForeignKeyData.ObjectName
         Get
            Return Element.@Name
         End Get
      End Property
#End Region

   End Class

End Namespace
